package com.tao.controller.webpageController;

import com.tao.pojo.dto.OrderCancelDto;
import com.tao.pojo.dto.OrderRejectDto;
import com.tao.pojo.dto.PageSearchOrtderDto;
import com.tao.pojo.entity.OrderConfirmDto;
import com.tao.result.Result;
import com.tao.service.OrderStoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/webPage/storeOrder")
@Slf4j
public class OrderControllerStore {
    @Autowired
    OrderStoreService orderStoreService;

    @GetMapping("/search")
    public Result orderSearch(PageSearchOrtderDto pageSearchOrtderDto){
        return Result.success(orderStoreService.orderSearch(pageSearchOrtderDto));
    }

    @GetMapping("statistic")
    public Result orderStatisticStatus(){

        return Result.success(orderStoreService.orderStatisticStatus());
    }

    @GetMapping("/orderDetail/{id}")
    public Result getOrderDetail(@PathVariable Integer id){
        return Result.success(orderStoreService.getOrderDetail(id));
    }

    @PutMapping("/rejection")
    public Result rejectOrder(@RequestBody OrderRejectDto orderRejectDto){
        orderStoreService.rejectionOrder(orderRejectDto);
        return Result.success();
    }

    @PutMapping("/cancel")
    public Result cancelOrder(@RequestBody OrderCancelDto orderCancelDto){
        orderStoreService.cancelOrder(orderCancelDto);
        return Result.success();
    }

    @PutMapping("/confirm")
    public Result confirmOrder(@RequestBody OrderConfirmDto orderConfirmDto){
        orderStoreService.confirmOrder(orderConfirmDto);
        return Result.success();
    }

    @PutMapping("/delivery/{id}")
    public Result deliveryOrder(@PathVariable Integer id){
        orderStoreService.deliveryOrder(id);
        return Result.success();
    }

    @PutMapping("/complete/{id}")
    public Result completeOrder(@PathVariable Integer id){
        orderStoreService.completeOrder(id);
        return Result.success();
    }
}
